require(['./config'],function(){
	require(['jquery','loadHF'],function($){
		class reg{
			constructor() {
			    this.addListener()
			}
			addListener(){
				$(".reg-submit").on("click",this.regsub)
			}
			regsub(e){
				e.preventDefault()
				const _form=$(e.target).parents("form")
				// console.log($(_form).find("input:nth-of-type(4)").val())
				const _password=$(_form).find("input:nth-of-type(4)").val()
				if(_password===$(_form).find("input:nth-of-type(5)").val()){
					const _data=`phonenumber=${$(_form).find("input:nth-of-type(1)").val()}&password=${_password}`
					// console.log(data)
					$.post("/api/register.php",_data,function(q){
						console.log(q)
						console.log(q.data.status)
						if(q.data.status==1){
							// console.log("aa")
							location="/html/login.html"
						}else{
							// console.log("bb")
							$("form p:nth-of-type(1)").css("display","inline-block")
							$(_form).find("input:nth-of-type(1)").val("")
							$(_form).find("input:nth-of-type(4)").val("")
							$(_form).find("input:nth-of-type(5)").val("")
						}
					},'json')
				}else{
					$("form p:nth-of-type(2)").css("display","inline-block")
					$(_form).find("input:nth-of-type(5)").val("")
					$(_form).find("input:nth-of-type(4)").val("")
				}
				
			}
		}
		new reg()
	})
})